import gradio as gr

# 定义逆序函数
def reverse_text(text):
    return text[::-1]

# 实例化Blocks对象
with gr.Blocks() as demo:
    gr.Markdown("# 文本逆序应用")
    with gr.Row():
        input_text = gr.Textbox(label="请输入一段话")
        output_text = gr.Textbox(label="逆序输出")
    btn = gr.Button(value="提交", variant="primary")
    # 绑定按钮点击事件
    btn.click(fn=reverse_text, inputs=input_text, outputs=output_text)

demo.launch()